#!/user/bin/env python3
# -*- coding: utf-8 -*-
"""
--------------------------------------
    Author:     JiChao_Song
    Date  :     2022/2/10 15:03
    Desc  :
--------------------------------------
"""
from __future__ import absolute_import

from celery import platforms
from django_http_log.models import Log

from person.dto.PersonLoginLogDto import PersonLoginLogAddDto
from person.models.person import RPCLog, PersonLoginLog
from platform_auth import celery_app

platforms.C_FORCE_ROOT = True


@celery_app.task
def add_log_task(data):
    """添加日志"""

    Log(**data).save()

    return None


@celery_app.task
def add_rpc_log_task(data):
    """添加日志"""

    RPCLog(**data).save()

    return None


@celery_app.task
def login_log_record_task(personLoginLogAddDto:PersonLoginLogAddDto.__dict__):
    """登陆日志记录"""

    PersonLoginLog(
        **personLoginLogAddDto
    ).save()
    return personLoginLogAddDto